CX_VALUE_PER
Class hierarchy
- CX_CLASS
- CX_AMOUNT
- CX_NUMERIC
- CX_VALUE
- CX_VALUE_PER
- CX_VALUE
- CX_NUMERIC
- CX_AMOUNT
Description:
The class allows to link one value to another value. This is usually the case with price quotations such as "10 DM per 5 pieces". Calculations are only possible if the other object is based on the same reference value.
Code example:
Display on screen
The following options exist for displaying objects of this class:
1. use of a surface object of type String. In this case the object is specified in a single input field. The two values ("numerator" and "denominator") are entered or displayed separately by the system's defined separator for fractions , as shown in the following figure(programme code):
2. the use of two surface objects of type String, where the "numerator" is entered in one field and the "denominator" in the other (programme code):
Note: As the components of a range value are values, the corresponding input and output options apply to them. This means that e.g. the counter can be addressed via two surface objects, one is responsible for the number and the other for the unit.
Behaviour with Put
If the value of a CX_VALUE_PER object is set with a string, the following rules apply:
- If no denominator exists, the existing denominator is set to 1. The unit in the denominator is not changed.
The precision in the denominator is set to the system precision just set.
223665, the precision in the denominator is no longer changed because the behaviour did not match the behaviour when importing "#x/y". - If no numerator exists (e.g. "/3kg"), the numerator is imported with "0" (unit is retained) and the denominator with "3kg".
- The precision of the counter is maintained.
- The precision of the denominator is maintained if the string contains a denominator.
- The import of denominator and numerator is traced back to the behaviour of Put to CX_VALUE .
Attention: In contrast to the import of CX_VALUE, numerical values are always imported with full precision. With CX_VALUE, the precision set in the object determines the number of decimal places that are imported. - The import of an empty string is equivalent to the import of "0/1".
Operator | Brief description |
---|---|
+, -, *, / | Arithmetic |
+=, -=, *=, /= | Arithmetic |
>, <, = | Compare |
Function | MA* | Parameters | Return | Brief description |
---|---|---|---|---|
abs | OBJECT | Unsigned value | ||
Denominator | OBJECT | Return of the denominator | ||
Get1Value | OBJECT | Return: Value with denominator 1 and numerator 1 | ||
GetFraction | OBJECT | Value in fractional form | ||
GetNumeric | OBJECT | Return: Object as a real number | ||
GetValue | OBJECT | Returned: Object as value | ||
Numerator | OBJECT | Return of the counter | ||
NumericNumeratorMA | * | OBJECT | Return of the counter as CX_NUMERIC | |
Reciprocal | OBJECT | Create reciprocal value | ||
RoundAutomatically | OBJECT | Round the number with the precision that results from the unit | ||
RoundByPrecision | Rounding with current precision | |||
SetValuePer 231532 | STRING, INTEGER | Import range value from string | ||
UnitNumeratorMA | * | STRING | Returns the unit of the counter as STRING | |
Add | CX_AMOUNT | CX_AMOUNT | Operator + as function | |
AddAssign | CX_AMOUNT | Operator += as function | ||
AdjustPrecision | Adjusting the accuracy of the meter | |||
Amount | OBJECT | Return of the object value | ||
AmountWeak | CX_AMOUNT | |||
Car format | INTEGER, INTEGER | CX_AMOUNT | Returns a formatted object according to the given number of digits before and after the decimal point (only for CX_VALUE or derived classes, otherwise the object itself). | |
DivAssign | CX_AMOUNT | Operator /= as function | ||
Divide | CX_AMOUNT | CX_AMOUNT | Operator / as function | |
IsZero | INTEGER | Test number to zero | ||
MulAssign | CX_AMOUNT | Operator *= as function | ||
Multiply | CX_AMOUNT | CX_AMOUNT | Operator * as function | |
Precision | * | Changing the accuracy of the counter | ||
PrecisionAdjusted | OBJECT | like AdjustPrecision, but with return of the object | ||
Rounded | (INTEGER) | |||
SetNumeric | STRING, INTEGER | Import counter as CX_NUMERIC from string | ||
SetPrecision | (INTEGER) | Set number of decimal places for the counter | ||
SetValue | STRING, INTEGER | Import counter as CX_VALUE from the string | ||
SetZero | Set number to zero | |||
string | INTEGER | CX_STRING | Returns the string representation of the object | |
SubAssign | CX_AMOUNT | Operator -= as function | ||
Subtract | CX_AMOUNT | CX_AMOUNT | Operator - as a function | |
Unit | * | Input/output control of the counter unit | ||
ValueNumeratorMA | * | Access to counter value |
* MA = Member Access Function
Data field | Type | Reference class | I* | Brief description |
---|---|---|---|---|
this | CX_VALUE | The value | ||
val | CX_VALUE | The reference value or denominator | ||
denominator | CX_VALUE | like 'val'. |
* I = Indexable data field
Module | Brief description |
---|---|